package com.stars.services.impl.system;
import com.github.pagehelper.PageInfo;
import com.stars.entity.system.SysJsItemEntity;
import com.stars.services.system.SysJsItemAccessServices;
import com.stars.dao.mapper.system.SysJsItemMapper;
import com.stars.entity.dto.system.SysJsItemDTO;

import java.util.List;
import com.stars.entity.ListPage;
import com.github.pagehelper.PageHelper;
import com.stars.services.impl.BaseAccessServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Title: 前端组件 业务逻辑
 * @author dj
 * @date 2019-10-14 20:33:38
 * @version V1.0
 *
 */
@Service
public class SysJsItemAccessServicesImpl  extends BaseAccessServiceImpl<SysJsItemMapper , SysJsItemEntity> implements  SysJsItemAccessServices {
    @Autowired
    private SysJsItemMapper  sysJsItemMapper;


    /**
     * 分页查询
     * @param pageNum 查询参数 起始页，大小。
     * @return
     */
    @Override
    public PageInfo<SysJsItemDTO> pageList(Integer pageNum, Integer pageSize, SysJsItemDTO dto) throws Exception{
        ListPage<SysJsItemDTO> listPage = new ListPage<>(pageNum, pageSize, dto);
        PageHelper.startPage(pageNum, pageSize);
        List<SysJsItemDTO> list = sysJsItemMapper.pageQuerySysJsItem(listPage);
        PageInfo<SysJsItemDTO> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }

    @Override
    public List<SysJsItemDTO> findListByName(String name) throws Exception {
        if(StringUtils.isBlank(name)){
            return null;
        }
        return sysJsItemMapper.querySysJsItemList(name);
    }
}
